<template>
  <el-aside width="240px" class="image-aside" v-loading="loading">
    <div class="top">
      <div style="padding: 10px;border-bottom: 1px solid #eee;display: flex">
        <el-input v-model="keyword" placeholder="请输入文件名和标签"></el-input>
        <el-button type="primary" icon="search" @click="handleSearch" style="margin-left: 5px">搜索</el-button>
      </div>
      <div class="aside-list" @click="handleAsideChange(item.type)" v-for="(item,index) in list" :key="index" :class="{ 'active' : active }">
        <span class="truncate" >{{ item.title }} ({{item.total}})</span>
        <div v-if="false">
          <el-button class="ml-auto px-1" text type="primary" size="small" @click.stop="$emit('edit')">
            <el-icon :size="12"><Edit /></el-icon>
          </el-button>
          <span @click.stop="()=>{}">
              <el-popconfirm title="是否要删除该分类？" confirmButtonText="确认" cancelButtonText="取消" @confirm="$emit('delete')">
                  <template #reference>
                      <el-button text class="px-1" type="primary" size="small">
                          <el-icon :size="12"><Close /></el-icon>
                      </el-button>
                  </template>
              </el-popconfirm>
          </span>
        </div>
      </div>
    </div>
    <div class="bottom" v-if="false">
      <el-pagination background layout="prev, next" :total="10" :current-page="1" :page-size="10" @current-change="getData"/>
    </div>
  </el-aside>
</template>
<script setup>
import {statistics} from "@/api/resource";
const emits = defineEmits(["handleAsideChange"])
const keyword=ref("")
var loading = ref(false)
var active = ref(false)
const type=ref(1)
const handleAsideChange=(types)=>{
  type.value=types
  emits("handleAsideChange",type.value,keyword.value)
}
const handleSearch=()=>{
  emits("handleAsideChange",type.value,keyword.value)
}
const list = ref([])
const handleLoad=async () => {
  const res = await statistics();
  list.value=res.data
}

onMounted(()=>{
  handleLoad()
})
</script>
<style>
.aside-list{
  border-bottom: 1px solid #f4f4f4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding:10px 20px;
  font-size:12px;
  color:#666;
}
.aside-list:hover,.active{
  background: rgba(85, 160, 248, 0.18);
}

.image-aside{
  border-right: 1px solid #eeeeee;
  position: relative;
}

.image-aside .top
{
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 50px;
  overflow-y: auto;
}
.image-aside .bottom
{
  position: absolute;
  bottom: 0;
  height: 50px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top:1px solid #f5f7f9;
}

</style>